package com.yonyou.pmclouds.safetypatrol.service.rmiimpl;

import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.ref.itf.RefCodeConst;
import com.yonyou.pmclouds.basecom.ref.itf.ReferenceCheckOfBusiness;
import com.yonyou.pmclouds.safeinspection.entity.SafeInspectionVO;
import com.yonyou.pmclouds.safeinspection.rmiitf.SafeinspectionQueryService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author xu
 */
@Component
public class ReferenceCheckOfSafetypatrol implements ReferenceCheckOfBusiness {

    @Resource
    private SafeinspectionQueryService queryService;


    @Override
    public String[] getReferenceCode() {
        return new String[]{RefCodeConst.PROJECT, RefCodeConst.SAFETYPATROL};
    }

    @Override
    public boolean checkReferenced(String bdCode, String[] keys) throws BusinessException {
        String code =null;
        if (RefCodeConst.PROJECT.equals(bdCode)){
            code = SafeInspectionVO.PK_PROJECT;
        }else if (RefCodeConst.SAFETYPATROL.equals(bdCode)){
            code = SafeInspectionVO.PK_SAFETYPATROL;
        }else {
            throw new BusinessException("安全巡查暂未引用该档案");
        }


        return queryService.queryRefByIds(code,keys);
    }
}
